package com.lanzx.gulimall.search.controller;

import com.lanzx.gulimall.search.service.MallSearchService;
import com.lanzx.gulimall.search.vo.SearchParam;
import com.lanzx.gulimall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author: lanzx
 * @description: 负责界面跳转
 * @date: 2021/1/7 15:02
 */
@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;

    @GetMapping("list.html")
    public String listPage(@RequestParam SearchParam param, Model model) {
        //1 根据传递来的参数，去es中检索
        SearchResult result = mallSearchService.search(param);
        model.addAttribute("result", result);
        return "list";
    }
}
